<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
        <link rel="stylesheet" type="text/css" href="layui\css\layui.css">
        <script src="layui\layui.js"></script>
        <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
    </head>
    <body>

        <input type="text" class="layui-input select-date" lay-verify="required" id="test1" placeholder="我是test1, 快点我 "
            value="">


        <div class="layui-col-xs12 layui-col-sm6">
            <label class="layui-form-label"><em class="require-mark">*</em>社会信用代码证有效期</label>
            <div class="layui-input-inline">
                <input type="text" id="licenseValidityDate" name="merchantInfo.license_validity_date" placeholder="社会信用代码证有效期"
                    class="layui-input select-date" lay-verify="required" required value="" autocomplete="off" />
            </div>
        </div>
    </body>

    <script>
        var date = new Date();
        console.log(date);
        console.log(date.toDateString());
        console.log(date.getFullYear() + "-" + date.getMonth() + "-" + date.getDay());

        var minDate = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
        console.log(minDate);
        minDate = '2020-08-06 11:18:13';
        layui.use('laydate', function() {
            var laydate = layui.laydate;


            //执行一个laydate实例
            var ins1 = laydate.render({
                elem: '#test1', //指定元素
                type: 'datetime' // 指定时间日期控件
                    ,
                min: minDate //最小可选日期, 就是今天
                    // min: 0, //更快
                    ,
                max: 7, //7天后
                //初始打开的回调
                format: 'yyyy-MM-dd HH:mm:ss', //可任意组合

                ready: function(date) {
                    console.log("ready");
                    console.log(date); //得到初始的日期时间对象：{year: 2017, month: 8, date: 18, hours: 0, minutes: 0, seconds: 0}
                    $(".layui-laydate-footer [lay-type='datetime'].laydate-btns-time").click();
                    $(".laydate-main-list-0 .layui-laydate-content li ol li:last-child").click();
                    $(".layui-laydate-footer [lay-type='date'].laydate-btns-time").click();


                },
                //选择完毕的回调
                done: function(value, date, endDate) {
                    console.log(value); //得到日期生成的值，如：2017-08-18
                    console.log(date); //得到日期时间对象：{year: 2017, month: 8, date: 18, hours: 0, minutes: 0, seconds: 0}
                    console.log("done");
                    console.log(endDate); //得结束的日期时间对象，开启范围选择（range: true）才会返回。对象成员同上。          
                    ins1.hint(value); //在控件上弹出value值

                    var hours = endDate.hours;
                    var minutes = endDate.minutes;
                    var seconds = endDate.seconds;



                }


            });



            //社会信用代码证有效期
            laydate.render({
                elem: '#licenseValidityDate',
                min: 0
            });

        });
    </script>
</html>
